layui.use(['form','layer','laydate','table','util'],function (){
    let form = layui.form,layer = layui.layer,laydate = layui.laydate,table = layui.table,util = layui.util;
    let dateElem = $('.form-dateElem');
    //渲染日期模块，最大日期为当前日期
    layui.each(dateElem,function () {
        laydate.render({
            elem:this,
            //最大日期比今天多几天
            max:0,
        })
    })
})

/**
* @author: ChengJW
* @params:
* @return:
* @date: 2021/9/22
* @description: 初始化生成table数据
*/
$(function () {
    selectExceptionInfo();
})

/**
* @author: ChengJW
* @params:
* @return:
* @date: 2021/9/22
* @description: 生成table数据
*/
function selectExceptionInfo() {
    //起始日期
    let stDt = $('#stDt').val();
    //截止日期
    let lmDt = $('#lmDt').val();
    //用户名称
    let exUserName = $("#exUserName").val().trim();

    let stDtExce = valueClean(stDt,"-");
    let lmDtExce = valueClean(lmDt,"-");
    if (!valueIsEmpty(stDt) && ! valueIsEmpty(lmDt) && stDtExce > lmDtExce){
        top.layer.alert("起始日期不能大于截止日期");
        return;
    }
    let jsonData = {
        "qryReqFir" : exUserName,
        "stDt" : stDt,
        //在此处作为截止时间传值
        "lmDt" : lmDt
    }
    //时间戳
    let tabTitle = '系统日志信息表'+layui.util.toDateString(new Date(),'yyyyMMddHHmmss');
    layui.table.render({
        elem:'#dataTable',
        id:'dataTableId',
        url:'/systemDefend/exceptionAdmin/selectExceptionInfo',
        parseData:function (result) {
            return{
                "code":result.code,
                "msg":result.msg,
                "count":result.data.pageCount,
                "data":result.data.list
            }
        },
        size:'sm',
        //分页的起止页号，每页条数
        page:{
            curr:1,
            limit:15,
            limits:[15,30,50,100]
        },
        //自定义的页码参数名称、每页条数参数名称
        request:{
            pageName:'pageNum',
            limitName:'pageSize'
        },
        //table的高度
        height:550,
        //查询条件，json格式
        where:jsonData,
        cols:[[
            {type:'checkbox'},
            {type:'numbers',title:'序号'},
            {field:'exId',title:'异常编码'},
            {field:'exUserName',title:'登录人账号'},
            {field:'exUserRealName',title:'登录人姓名'},
            {field:'exUserCode',title:'登录人所属机关代码'},
            {field:'exClass',title:'异常类'},
            {field:'exMethod',title:'异常方法'},
            {field:'exMsg',title:'异常简讯',width: 150},
            {field:'exDesc',title:'异常描述'},
            {field:'stDt',title:'异常日期'}
        ]],
        //头部工具条
        toolbar: true,
        //导出时候excel文件标题
        title:tabTitle
    });
}